<template>
	<view class="page">
		<navbar title="河南营商环境入企监测" bgColor="transparent" :titleStyle="titleStyle"></navbar>
		<scroll-view class="scroll-view_H safe-area-inset-bottom"
			:style="{height: 'calc(100vh - ' + (safeAreaHeight + 30)+'px)'}" scroll-y="true">
			<view class="home-bg">
				<image mode="widthFix" style="width: 100%;display: block;" src="@/static/home/home-bg.jpg"></image>
				<view class="current-visit-card">
					<view class="content" style="display: flex;overflow: hidden;">
						<view style="height: 61px; width: 100%; display: flex;align-items: center;">
							<view class="avator">
								<image mode="widthFix" style="width: 110rpx;height: 110rpx; display: block;"
									:src="avatorUrl"></image>
							</view>
							<template v-if="isLogin">
								<view
									style="overflow: hidden; flex: 1;height: 100%; display: flex;flex-direction: column;justify-content: space-between;padding-left: 20rpx;">
									<view style="display: flex;align-items: center;width: 100%;">
										<text
											style="font-size: 30rpx;color: #323232;padding: 0px;">{{userInfo.fontUser.userName || '-'}}</text>
										<text v-if="isEnterprise" class="company-name"
											style="font-size: 30rpx;">{{ userInfo.departmentName?('(' + userInfo.departmentName + ')'):'' }}</text>
										<text v-if="!isEnterprise && !userInfo.isAuthentication"
											style="font-size: 28rpx;color: #1169DB;font-weight: bold;margin-left: 20px;"
											@click="toNewCompany">去认证企业</text>
										<text v-if="!isEnterprise && userInfo.isAuthentication" class="company-name"
											style="font-size: 30rpx;">{{ (currentCompanyInfo && currentCompanyInfo.companyName)?('(' + currentCompanyInfo.companyName + ')'):'' }}</text>
										<image v-if="!isEnterprise && userInfo.isAuthentication" @click="toCompanyList"
											mode="widthFix"
											style="width: 40rpx;height: 40rpx;margin-left: 20rpx; display: block;"
											src="@/static/switch-ico.png"></image>
									</view>
									<view style="display: flex;align-items: center;justify-content: space-between;">
										<!-- <text class="personal" @click="toPersonal">个人中心</text> -->
										<text
											class="personal">{{(!isEnterprise && userInfo.isAuthentication)?'企业用户':(!isEnterprise && !userInfo.isAuthentication)?'普通用户':(isEnterprise && userInfo.lawEnforcementOfficials)?'执法人员':(isEnterprise && !userInfo.lawEnforcementOfficials)?'普通入企人员':''}}</text>
										<view v-if="true" @click="exit">
											<text style="font-size: 28rpx;color: #1169DB;font-weight: bold;">退出</text>
										</view>
									</view>
								</view>

							</template>
							<template v-else>
								<view
									style="flex: 1; display: flex;flex-direction: column;justify-content: space-around;margin-left: 20rpx;">
									<text style="font-size: 28rpx;color: #323232;">您好！游客</text>
								</view>
								<view style="display: flex;height: 60rpx;align-items: center;">
									<text style="font-size: 28rpx;color: #1169DB;font-weight: bold;padding: 0px 14px;"
										@click="checkOpenId">点击登录</text>
									<!-- <button class="login-bt" open-type="getPhoneNumber"
										@getphonenumber="getPhoneNumber">点击登录</button> -->
								</view>
							</template>

						</view>
					</view>
				</view>
			</view>
			<view class="operate-cn" v-if="true">
				<u-icon name="info-circle" size="19" color="#1169DB"></u-icon>
				<text style="flex: 1;margin-left: 3px;">不知道亮码扫码怎样操作?</text>
				<view style="display: flex;align-items: center;" @click="viewDocument">
					<text style="margin-right: 3px;">查看</text>
					<u-icon name="arrow-right" size="19" color="#1169DB"></u-icon>
				</view>
			</view>
			<view class="title-line">
				<view class="line-dot" style="justify-content: flex-end;">
					<view style="width: 6px;height: 6px;background-color: #1169DB;border-radius: 50%;"></view>
				</view>
				<text>河南营商环境入企监测</text>
				<view class="line-dot" style="justify-content: flex-start;">
					<view style="width: 6px;height: 6px;background-color: #1169DB;border-radius: 50%;"></view>
				</view>
			</view>

			<view class="menu-card" style="margin-top: 25rpx;">
				<view class="menu-item" style="margin-left: 10px;" @click="jumpTo(1)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu1-ico.png">
						</image>
						<text style="margin-top: 5px;">{{userInfo.isEnterprise?'入企人员码':'我的营商码'}}</text>
					</view>


				</view>
				<view class="menu-item" style="margin: 0px 10px;" @click="jumpTo(2)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu2-ico.png">
						</image>
						<text style="margin-top: 5px;">扫一扫</text>
					</view>
				</view>
				<!-- <view
				    :class="['menu-item', (userInfo && !userInfo.isAuthentication && !userInfo.isEnterprise) ?'prohibit':'']"
					style="margin: 0px 10px;" @click="jumpTo(2)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu2-ico.png">
						</image>
						<text style="margin-top: 5px;">扫一扫</text>
					</view>
				</view> -->
				<view class="menu-item" style="margin-right: 10px;" @click="jumpTo(3)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu3-ico.png">
						</image>
						<text style="margin-top: 5px;">入企监测</text>
					</view>

				</view>

			</view>

			<view class="menu-card">
				<view class="menu-item" style="margin-left: 10px;" @click="jumpTo(4)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu4-ico.png">
						</image>
						<text style="margin-top: 5px;">政策查询</text>
					</view>


				</view>
				<view :class="['menu-item',userInfo.isEnterprise?'prohibit':'']" style="margin: 0px 10px;"
					@click="jumpTo(5)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx; display: block;"
							src="@/static/home/menu5-ico.png">
						</image>
						<text style="margin-top: 5px;">企业心声</text>
					</view>
				</view>
				<view :class="['menu-item',(userInfo.isEnterprise || openQyxsYsjc == 'N')?'prohibit':'']"
					style="margin-right: 10px;" @click="jumpTo(6)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu6-ico.png">
						</image>
						<text style="margin-top: 5px;">营商监测</text>
					</view>

				</view>

				<!-- <view :class="['menu-item']" style="margin: 0px 10px;"
					@click="jumpTo(5)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx; display: block;"
							src="@/static/home/menu5-ico.png">
						</image>
						<text style="margin-top: 5px;">企业心声</text>
					</view>
				</view>
				<view :class="['menu-item']"
					style="margin-right: 10px;" @click="jumpTo(6)">
					<view class="content menu-default">
						<image mode="widthFix" style="width: 70rpx;height: 70rpx;display: block;"
							src="@/static/home/menu6-ico.png">
						</image>
						<text style="margin-top: 5px;">营商监测</text>
					</view>
				
				</view> -->
			</view>


		</scroll-view>
		<!-- <view class="bottom-info">
			<text>河南省发展改革委员会主办</text>
		</view> -->
		<!-- 消息提示-->
		<u-toast ref="uToast"></u-toast>
		<!-- 登录 -->
		<u-popup :show="showLogin" :round="10" @close="close" mode="center" :closeOnClickOverlay="false">
			<view class="login-form">
				<view class="header-title">
					<text>请注册</text>
				</view>
				<u-line></u-line>
				<view class="basic-title">
					<text>基本信息</text>
				</view>
				<u-line></u-line>
				<u--form ref="uForm" labelPosition="left" :model="formData" :rules="rules" labelWidth="90"
					:labelStyle="labelStyle">

					<!-- <u-form-item label="手机号" prop="phone" borderBottom>
						<u--input v-model="formData.phone" border="none"></u--input>
					</u-form-item> -->
					<u-form-item label="手机号" prop="phone" borderBottom>
						<u-input v-model="formData.phone" type="number" maxlength="11" placeholder="请输入手机号"
							border="none">
							<template slot="suffix">
								<view v-if="isPhoneCode" @click="getMsgCode" class="custom-button">
									<text>验证码</text>
								</view>
								<view v-else class="custom-button">
									<text>{{countDownPhone+'s'}}</text>
								</view>
							</template>
						</u-input>
					</u-form-item>
					<u-form-item label="短信验证码" prop="code" borderBottom>
						<u--input v-model="formData.code" type="number" placeholder="请输入短信验证码" border="none"></u--input>
					</u-form-item>
					<u-form-item label="姓名" prop="name" borderBottom>
						<u--input v-model="formData.name" placeholder="请输入姓名" border="none"></u--input>
					</u-form-item>
					<u-form-item label="身份证号" prop="idCard" borderBottom>
						<u--input v-model="formData.idCard" type="idcard" maxlength="18" placeholder="请输入身份证号"
							border="none"></u--input>
					</u-form-item>
				</u--form>
				<view style="padding: 20rpx 0px;">
					<text
						style="font-size: 26rpx;color: #999;">请输入您的身份信息，若您是企业关联人员，我们将引导您关联您的企业信息。若您是行政执法人员，我们将关联您的身份信息。</text>
				</view>
				<view style="margin-top: 50rpx;">
					<u-button :throttleTime="1000" :loading="registerLoading" type="primary" text="确定"
						@click="loginSubmit"></u-button>
				</view>
				<view style="margin-top: 20rpx;">
					<u-button type="primary" :plain="true" text="取消" @click="close"></u-button>
				</view>

			</view>
		</u-popup>


		<!-- loading -->
		<u-overlay :show="showLoading" :opacity="0.8">
			<view class="warp">
				<text style="font-size: 28rpx;color: #fff;">加载中...</text>
			</view>
		</u-overlay>

		<tab-bar :selected="selected"></tab-bar>


	</view>
</template>

<script>
	import {
		checkDate,
		checkProv,
		checkParity,
		checkPhone,
		toast,
		showConfirm,
		getSq,
		getMidString,
	} from "@/utils/common.js"
	import {
		getHeadSculpture,
		getWxPhone,
		sendSmsCode,
		getConfig,
		getSocialCredit,
	} from '@/api/pagesMine'
	import store from '@/store'
	import user from "../../store/modules/user";
	import TabBar from "@/components/tabBar.vue"
	import {
		decrypt,
		encrypt,
	} from '@/utils/sm4.js'
	let App = getApp();
	export default {
		components: {
			TabBar,
		},
		data() {
			return {
				registerLoading: false,
				selected: 0,
				showLoading: false,
				avatorUrl: require('@/static/home/avator.png'),
				safeAreaHeight: App.globalData.safeAreaHeight,
				isLogin: false,
				isEnterprise: false,
				exitContent: "确认退出当前账号？",
				showLogin: false,
				titleStyle: {
					color: "#ffffff",
					fontWeight: "bold",
					fontSize: "18px"
				},
				labelStyle: {
					color: "#323232",
					fontWeight: "bold",
					fontSize: "28rpx"
				},
				formData: {
					name: "",
					phone: "",
					idCard: "",
					code: "",
					// name: "张东林",
					// phone: "13683825857",
					// idCard: "412828199204063054",
					// code: "",
					// name: "郭子",
					// phone: "15188362310",
					// idCard: "610822198107035927",
					// code: "",
				},
				isPhoneCode: true,
				countDownPhone: 60,
				totalSecond: 60,
				timer1: null,
				rules: {
					name: [{
						required: true,
						message: '请输入姓名',
						trigger: ['blur']
					}],
					phone: [{
						required: true,
						message: '请输入手机号',
						trigger: ['blur']
					}, {
						// 自定义验证函数
						validator: (rule, value, callback) => {
							var checkID = (value) => {
								if (checkPhone(value)) {
									return true;
								} else {
									return false
								}
							}
							return checkID(value);
						},
						message: '手机号格式不正确',
						// 触发器可以同时用blur和change
						trigger: ['blur'],
					}],
					code: [{
						required: true,
						message: '请输入短信验证码',
						trigger: ['blur']
					}],
					idCard: [{
							required: true,
							message: '请输入身份证号',
							trigger: ['blur', 'change']
						},
						{
							// 自定义验证函数
							validator: (rule, value, callback) => {
								var checkID = (value) => {
									if (checkDate(value)) {
										if (checkProv(value.substring(0, 2))) {
											if (checkParity(value)) {
												return true;
											} else {
												return false;
											}
											return true;
										} else {
											return false
										}
									} else {
										return false
									}
								}
								return checkID(value);
							},
							message: '身份证不正确',
							// 触发器可以同时用blur和change
							trigger: ['blur', 'change'],
						},
					],
				},
				userInfo: store.state.user.USER_INFO,
				currentCompanyInfo: store.state.user.COMPANY_INFO,
				docementUrl: [],
				openQyxsYsjc: "N",

			};
		},
		onLoad() {
			this.getDocument()
			this.isLogin = this.userInfo ? true : false
			this.isEnterprise = this.userInfo ? this.userInfo.isEnterprise : false
			this.$eventBus.$off('Home')
			this.$eventBus.$on('Home', (param) => {
				if (param == 'login') {
					/* 登录 */
					this.showLogin = true
				}
				if (param == 'avstorRefresh') {
					/* 刷新头像 */
					this.getHeaderAvstor()
				}
				if (param == 'logOff') {
					this.exitReset()
				}
			})
			console.log(encrypt('91410100MAETU8KF47'), '88888888888888888888888888')
		},
		onShow() {
			this.getDisable()
			this.currentCompanyInfo = store.state.user.COMPANY_INFO
			this.userInfo = store.state.user.USER_INFO
			this.isLogin = this.userInfo ? true : false
			this.isEnterprise = this.userInfo ? this.userInfo.isEnterprise : false
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules)
		},
		methods: {
			close() {
				this.showLogin = false
				this.showLoading = false
				this.registerLoading = false
				this.formData.name = ""
				this.formData.phone = ""
				this.formData.code = ""
				this.formData.idCard = ""
			},
			/* 退出登录 */
			exit() {
				showConfirm('确认退出登录状态?').then(res => {
					if (res.confirm) {
						this.$store.dispatch('user/logout').then(() => {
							uni.$u.toast('退出成功！')
							this.exitReset()
							this.$eventBus.$emit('Mine', 'clear')

						});
					}
				})
			},
			/* 退出数据重置 */
			exitReset() {
				this.close()
				this.avatorUrl = require('@/static/home/avator.png')
				this.isLogin = false
				this.currentCompanyInfo = null
				this.userInfo = null
			},
			/* 校验openid是否存在 */
			checkOpenId() {
				let openId = this.$store.state.user.USER_OPENID
				if (openId) {
					this.getPhone()
				} else {
					this.$store.dispatch('user/getWxOpenId').then((res) => {
						this.getPhone()
					});
				}
			},
			getPhone() {
				// this.showLogin = true
				let openId = this.$store.state.user.USER_OPENID
				this.$store.dispatch('user/Login', {
					userId: openId
				}).then((res) => {
					if (res.code == 200) {
						uni.$u.toast('登录成功！')
						/* 获取用户头像 */
						this.getHeaderAvstor()
						let currentCompany = null
						if (res.data.userCompanyRecords && res.data.userCompanyRecords.length >
							0) {
							currentCompany = res.data.userCompanyRecords.find(item => item.def ==
								0)
						}
						this.currentCompanyInfo = currentCompany
						this.userInfo = res.data
						this.showLogin = false
						this.isLogin = true
						this.isEnterprise = res.data.isEnterprise
						this.$eventBus.$emit('Mine', 'update')
					} else if (res.code == 401) { //未注册
						this.showLogin = true
					}

				});


			},
			/* 认证新企业 */
			toNewCompany() {
				uni.navigateTo({
					url: '/pages-mine/pages/newAuthenticationCompany/index'
				});
			},

			/* 跳转已认证企业列表 */
			toCompanyList() {
				uni.navigateTo({
					url: '/pages-mine/pages/myAuthentication/index?whereFrom=home'
				});
			},
			/* 登录 */
			loginSubmit() {
				this.$refs.uForm.validate().then(res => {
					/* 临时将手机号作为openid */
					// this.$store.commit('user/COMMIT_USER_OPENID', this.formData.phone)
					let openId = this.$store.state.user.USER_OPENID
					this.registerLoading = true
					this.$store.dispatch('user/Register', {
						userName: this.formData.name,
						mobile: this.formData.phone,
						idNumber: this.formData.idCard,
						code: this.formData.code,
						userId: openId
					}).then((res) => {
						uni.$u.toast('登录成功！')
						/* 获取用户头像 */
						this.getHeaderAvstor()
						let currentCompany = null
						if (res.data.userCompanyRecords && res.data.userCompanyRecords.length > 0) {
							currentCompany = res.data.userCompanyRecords.find(item => item.def == 0)
						}
						this.currentCompanyInfo = currentCompany
						this.userInfo = res.data
						this.showLogin = false
						this.isLogin = true
						this.isEnterprise = res.data.isEnterprise
						this.$eventBus.$emit('Mine', 'update')
						this.registerLoading = false
					}).catch(errors => {
						this.registerLoading = false
					});
				}).catch(errors => {
					this.registerLoading = false
				})
			},
			/* 跳转个人中心 */
			toPersonal() {
				uni.navigateTo({
					url: '/pages-mine/pages/personal/index'
				});
			},
			/* 查看操作文档 */
			viewDocument() {

				let userInfo = store.state.user.USER_INFO
				let url = ""
				if (userInfo && userInfo.isEnterprise) { //执法人员
					url = this.docementUrl[1]
				} else { //企业人员
					url = this.docementUrl[0]
				}
				uni.navigateTo({
					url: '/pages/home/operateDocument?imageUrl=' + url
				});
				// this.showLoading = true
				// uni.downloadFile({
				// 	url: url, //文件地址
				// 	success: (data) => {
				// 		//打开文档查看
				// 		uni.openDocument({
				// 			filePath: data.tempFilePath,
				// 			success: (res) => {
				// 				this.showLoading = false
				// 			},
				// 			fail: (err) => {
				// 				this.showLoading = false
				// 				return uni.$u.toast('预览失败')
				// 			}
				// 		});
				// 	},
				// 	fail: (err) => {
				// 		this.showLoading = false
				// 		return uni.$u.toast('预览失败')
				// 	},
				// });

			},
			/* 跳转 */
			jumpTo(type) {
				let _that = this
				let userInfo = store.state.user.USER_INFO
				if (!userInfo) {
					uni.$u.toast('请先登录!')
					return
				}
				if (type === 1) { //我的营商码
					if (userInfo.isEnterprise) {
						uni.navigateTo({
							url: '/pages-mall/pages/lawEnforceCertificate/index'
						});
					}
					if (!userInfo.isEnterprise) {
						let timerchuo = new Date().getTime()
						if (userInfo.isAuthentication) {
							uni.navigateTo({
								url: '/pages-mall/pages/myQrCode/detail?time=' + timerchuo
							});
						} else {
							uni.$u.toast('请先认证企业')
						}
					}
				}
				if (type === 2) { //扫一扫
					if (!userInfo.isEnterprise) {
						if (userInfo.isAuthentication) {
							uni.scanCode({
								success: (res) => {
									if (this.getQueryParam(res.result, 'userId') != '') {
										uni.navigateTo({
											url: '/pages-mall/pages/confirmTask/index?userId=' + this
												.getQueryParam(res.result, 'userId')
										});
									} else if (this.getQueryParam(res.result, 'view') == '1') { //详情
										uni.navigateTo({
											url: '/pages-mine/pages/enterCpRecord/detail?enterpriseTaskNo=' +
												this
												.getQueryParam(res.result, 'enterpriseTaskNo')
										});
									} else if (this.getQueryParam(res.result, 'view') == '2') {
										uni.navigateTo({
											url: '/pages-mall/pages/toTemporary/indexInfo'
										});
									} else {
										this.filterJump(res)
									}
								},
								fail: (err) => {
									console.error('扫描失败:', err);
								}
							});
						} else {
							uni.scanCode({
								success: (res) => {
									this.filterJump(res)
								},
								fail: (err) => {
									console.error('扫描失败:', err);
								}
							});
						}
					}
					/* 入企人员扫码 */
					if (userInfo.isEnterprise) {
						uni.scanCode({
							success: (res) => {
								this.filterJump(res)
							},
							fail: (err) => {
								console.error('扫描失败:', err);
							}
						});
					}
				}
				if (type === 3) { //入企记录
					uni.navigateTo({
						url: '/pages-mine/pages/enterCpRecord/index'
					});
				}
				if (type === 4) { //政策查询
					uni.navigateTo({
						url: '/pages-mall/pages/news/index'
					});
				}
				if (type === 5) { //企业心声
					if (userInfo.isEnterprise) {
						return
					}
					uni.navigateTo({
						url: '/pages-mall/pages/companyAspiration/index'
					});
				}
				if (type === 6) { //问卷调查
					if (userInfo.isEnterprise || this.openQyxsYsjc == 'N') {
						return
					}
					uni.navigateTo({
						url: '/pages-points/pages/myTest/index'
					});
				}

				// if (type === 5) { //企业心声
				// 	// if (userInfo.isEnterprise) {
				// 	// 	return
				// 	// }
				// 	uni.navigateTo({
				// 		url: '/pages-mall/pages/companyAspiration/index'
				// 	});
				// }
				// if (type === 6) { //问卷调查
				// 	// if (userInfo.isEnterprise || this.openQyxsYsjc == 'N') {
				// 	// 	return
				// 	// }
				// 	uni.navigateTo({
				// 		url: '/pages-points/pages/myTest/index'
				// 	});
				// }
			},
			/* 不同企业入企码特殊处理 */
			filterJump(res) {
				/* 商丘 */
				if (res.result.includes('/mobile/deptindex')) {
					let objs = getSq(res.result)
					this.scanResultRequest(objs.paramName, objs.id)
					return
				}
				/* 开封 */
				if (res.result.includes('bqt.kflz')) {
					let id = this.getQueryParam(res.result, 'id')
					this.scanResultRequest('bqt.kflz', id)
					return
				}
				/* 新郑 https://api.xzqyfw.cn/h5/#/pages/publish/company?id=349 */
				if (res.result.includes('xzqyfw')) {
					let id = this.getQueryParam(res.result, 'id')
					this.scanResultRequest('xzqyfw', id)
					return
				}
				/* 上街&荥阳 https://sjwgh.z.digitalcnzz.com:4431/gridEventReport/#/public/scan?tyshxydm=91410106687129205C */
				if (this.getQueryParam(res.result, 'tyshxydm') != '') {
					let socialCreditNumber = decrypt(this.getQueryParam(res.result,
						'tyshxydm'))
					this.scanResult(socialCreditNumber)
					return
				}
				/* 濮阳 http://61.54.164.122:81/visitor?companycode=91410928MA4114UE74 */
				if (this.getQueryParam(res.result, 'companycode') != '') {
					let socialCreditNumber = decrypt(this.getQueryParam(res.result,
						'companycode'))
					this.scanResult(socialCreditNumber)
					return
				}
				/* 规则A:https://yshj.fgw.henan.gov.cn?socialCreditNumber=kuyJlMio06tuZSDEsG6p+LD5Nh0OBKKQCbmmV/1xYg4=*/
				if (this.getQueryParam(res.result, 'socialCreditNumber') != '') {
					let socialCreditNumber = decrypt(this.getQueryParam(res.result,
						'socialCreditNumber'))
					this.scanResult(socialCreditNumber)
				} else {
					/* 济源市:https://msjd.zwfw.jiyuan.gov.cn/jiyuan-code-h5/home?companyId=1760588622852726788*/
					if (this.getQueryParam(res.result, 'companyId') != '') {
						let id = this.getQueryParam(res.result, 'companyId')
						this.scanResultRequest('', id)
						return
					}
					/* 信阳市 https://yssqm.hnynsoft.com/ys2/a?action=true&dataId=39313431313530304D414557354338483141 */
					if (this.getQueryParam(res.result, 'dataId') != '') {
						let id = this.getQueryParam(res.result, 'dataId')
						this.scanResultRequest('', id)
						return
					}
				}
			},
			/* 直接扫码跳转 */
			scanResult(socialCreditNumber) {
				//获取到二维码
				if (socialCreditNumber != '') {
					uni.navigateTo({
						url: '/pages-mall/pages/choseTask/index?socialCreditNumber=' +
							socialCreditNumber
					});
				} else {
					uni.$u.toast('未获取到企业信息!')
				}
			},
			/* 查询扫码跳转 1962452740503998465*/
			scanResultRequest(paramName, id) {
				getSocialCredit({
					paramName: paramName,
					enterpriseId: id
				}).then(res => {
					if (res.data == null) {
						uni.$u.toast('未获取到企业信息!')
					} else {
						uni.navigateTo({
							url: '/pages-mall/pages/choseTask/index?socialCreditNumber=' +
								res.data
						});
					}
				});

			},
			getQueryParam(str, param) {
				const url = str
				// 构造正则表达式，匹配 ? 或 & 后面跟随的参数名称和其值
				const regex = new RegExp('[?&]' + param + '=([^&#]*)', 'i');
				const result = regex.exec(url);
				return result ? decodeURIComponent(result[1]) : '';
			},
			/* 获取头像 */
			getHeaderAvstor() {
				let openId = this.$store.state.user.USER_OPENID
				getHeadSculpture(openId).then(res => {
					if (res.data && res.data.headSculpturePath != '') {
						this.avatorUrl = res.data.headSculpturePath
					} else {
						this.avatorUrl = require('@/static/home/avator.png')
					}
				});
			},
			/* 获取验证码 */
			getMsgCode() {
				if (this.formData.phone == '') {
					return uni.$u.toast('请填写手机号')
				}
				if (!checkPhone(this.formData.phone)) {
					return uni.$u.toast('请填写正确的手机号')
				}
				// 当前目前没有定时器开着，且 totalSecond 和 second 一致 (秒数归位) 才可以倒计时
				if (!this.timer1 && this.countDownPhone === this.totalSecond) {
					this.isPhoneCode = false
					// 开启倒计时
					this.timer1 = setInterval(() => {
						this.countDownPhone--
						if (this.countDownPhone <= 0) {
							clearInterval(this.timer1)
							this.timer1 = null // 重置定时器 id
							this.countDownPhone = this.totalSecond // 归位
							this.isPhoneCode = true
						}
					}, 1000)
					// 发送请求，获取验证码
					let openId = this.$store.state.user.USER_OPENID
					sendSmsCode({
						phoneNumber: this.formData.phone,
						userId: openId
					}).then(res => {
						// uni.$u.toast(res.data)
						uni.$u.toast("发送成功!")
					});

				}
			},
			/* 获取操作操作文档链接 */
			getDocument() {
				getConfig('wx.operate.document').then(res => {
					if (res.data) {
						this.docementUrl = res.data.split('&&')
					}
				});
			},
			/* 是否禁用企业心生和营商监测 */
			getDisable() {
				getConfig('system.open.qyxs.ysjc').then(res => {
					if (res.data) {
						this.openQyxsYsjc = res.data
					}
				});
			},
			/* 废弃获取微信手机号 */
			getPhoneNumber(res) {
				if (res.detail.errMsg == 'getPhoneNumber:ok') {
					getWxPhone({
						code: res.detail.code
					}).then(response => {
						let result = JSON.parse(response.data)
						if (result.errmsg == 'ok') {
							this.formData.phone = result.phone_info.phoneNumber
							this.showLogin = true
						} else {
							uni.$u.toast('获取手机号失败')
						}
					})
				} else {
					uni.$u.toast('未获取到手机号')
				}
			},
		}
	};
</script>

<style lang="scss" scoped>
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.operate-cn {
		background-color: rgb(236, 245, 255);
		display: flex;
		align-items: center;
		margin: 0px 10px 0px 12px;
		padding: 12px 12px;
		border-radius: 6px;
		color: #1169DB;
		font-size: 28rpx;
	}

	.custom-button {
		width: 140rpx;
		height: 54rpx;
		font-size: 24rpx;
		color: #fff;
		background: #3c9cff;
		border-radius: 6px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.bottom-info {
		height: 30px;
		display: flex;
		align-items: flex-end;
		justify-content: center;
		font-size: 24rpx;
		color: #8c8c8c;
	}

	.company-name {
		flex: 1;
		color: #8c8c8c;
		padding: 0px 12rpx;
		overflow: hidden;
		/*内容超出后隐藏*/
		text-overflow: ellipsis;
		/*超出内容显示为省略号*/
		white-space: nowrap;
		/*文本不进行换行*/
	}

	.login-form {
		width: calc(100vw - 100px);
		padding: 40rpx 40rpx 20rpx 40rpx;

		.header-title {
			display: flex;
			justify-content: center;
			font-size: 32rpx;
			color: #1169DB;
			font-weight: bold;
			padding-bottom: 30rpx;
		}

		.basic-title {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #1169DB;
			padding: 20rpx 0px;
		}

	}

	.login-bt {
		background: transparent;
		font-size: 28rpx;
		color: #1169DB;
		font-weight: bold;
	}

	.login-bt:after {
		border: none;
	}

	.list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 0 30rpx;
	}

	.dial-nav {
		padding: 24rpx 30rpx 30rpx 30rpx;
	}

	.scroll-view_H {
		width: 100%;
		height: 100%;

		.menu-card {
			width: 100%;
			padding-bottom: 24rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-around;

			.menu-item {
				flex: 1;
				padding: 26px 15px 15px 15px;
				background-color: #fff;
				box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.15);
				border-radius: 20rpx;

				.content {
					display: flex;
					flex-direction: column;
					align-items: center;
					font-size: 26rpx;
					color: #3d3d3d;
					font-weight: bold;

				}
			}

			.prohibit {
				background-color: #f0f0f0;

				.content {
					color: #8c8c8c;
				}

				image {
					opacity: .5;
				}
			}

		}

		.title-line {
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			font-size: 30rpx;
			font-weight: bold;
			color: #1169DB;

			.line-dot {
				margin: 0px 10px;
				display: flex;
				align-items: center;
				flex: 1;
				height: 1px;
				background-color: #1169DB;
			}
		}

		.home-bg {
			width: 100%;
			padding-bottom: 80px;
			position: relative;


			.current-visit-card {
				width: 94%;
				background-color: #fff;
				border-radius: 18rpx;
				box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.15);
				display: flex;
				position: absolute;
				bottom: 10px;
				left: 3%;

				.content {
					flex: 1;
					height: 100%;
					padding: 34rpx 30rpx;

					.avator {
						width: 110rpx;
						height: 110rpx;
						border-radius: 50%;
						overflow: hidden;
					}

					.personal {
						font-size: 22rpx;
						color: #fff;
						background-color: #1169DB;
						padding: 4rpx 20rpx;
						text-align: center;
						border-radius: 12rpx;
					}

				}
			}
		}

	}
</style>